﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GenerateKeyQLTH
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private static String getMyCode(String _input)
        {
            String result = System.Math.Abs(_input.GetHashCode()).ToString();
            if (result.Length > 4)
                return result.Substring(0, 4);
            else
                return result;
        }

        private void generateKey()
        {
            String ma = "";
            ma += getMyCode(tb_TenTruong.Text);
            ma += getMyCode(tb_DiaChi.Text);
            ma += getMyCode(tb_DienThoai.Text);
            ma += getMyCode(tb_Fax.Text);
            ma += getMyCode(tb_Website.Text);
            ma += getMyCode(tb_Email.Text);

            tb_MaDangKy.Text = ma;
        }

        private void tsb_Luu_Click(object sender, EventArgs e)
        {
            generateKey();
        }
    }
}
